<!DOCTYPE html>
<HTML>
<HEAD><meta name="viewport" content="width=device-width, initial-scale=1">
<Title>Borderless Bar Chart</Title>
<link type='text/css' rel='Stylesheet' href="maxchartapi.css" />
</HEAD>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">

<p class="heading0">ChartDirector 7.0 (Java Edition)</p>
<p class="heading1">Borderless Bar Chart</p>
<hr class="separator">
<div class="content">
<img src="images/hbar.png" width='600' height='250'>
<br><br>
This example demonstrates a horizontal bar chart with no axes, grid lines or and plot area border. It also demonstrates using gradient colors for the bars, and a number of other ChartDirector features.<br><br>
The key features demonstrated in this example are:<br><br>
<ul><li> Swap the x and y axes to create a horizontal bar chart using <a href="XYChart.swapXY.htm">XYChart.swapXY</a>.<br><br>
<li> Create a gradient color that changes smoothly from dark green to white along a horizontal direction using <a href="BaseChart.gradientColor.htm">BaseChart.gradientColor</a>, then use it as the bar color in <a href="XYChart.addBarLayer.htm">XYChart.addBarLayer</a>.<br><br>
<li> Set the plot area background, border and grid line colors to <a href="Chart.Transparent.htm">Transparent</a> using <a href="XYChart.setPlotArea.htm">XYChart.setPlotArea</a>.<br><br>
<li> Set the x-axis, y-axis and y-axis labels to <a href="Chart.Transparent.htm">Transparent</a> using <a href="Axis.setColors.htm">Axis.setColors</a>.<br><br>
<li> Set the x-axis font style to deep red 10 points Arial Bold Italic by using the <a href="TextBox.setFontStyle.htm">TextBox.setFontStyle</a> and <a href="TextBox.setFontColor.htm">TextBox.setFontColor</a> of the <a href="TextBox.htm">TextBox</a> object that represents the x-axis label prototype (obtained using <a href="Axis.setLabels.htm">Axis.setLabels</a>).<br><br>
<li> Set the aggregate bar label style to deep red 10 points Times Bold Italic using <a href="Layer.setAggregateLabelStyle.htm">Layer.setAggregateLabelStyle</a>.<br><br>
<li> Customize the aggregate bar labels by using <a href="Layer.setAggregateLabelFormat.htm">Layer.setAggregateLabelFormat</a>.</ul>
</div>
<p class="heading1a">Source Code Listing</p>
<div class="content">
<b>[JSP Version]</b> jspdemo/hbar.jsp
<div class='codeblock'><code class='pre'>&lt;%@page import="ChartDirector.*, java.util.*" %&gt;
&lt;%
// The data for the bar chart
double[] data = {3.9, 8.1, 10.9, 14.2, 18.1, 19.0, 21.2, 23.2, 25.7, 36};

// The labels for the bar chart
String[] labels = {"Bastic Group", "Simpa", "YG Super", "CID", "Giga Tech", "Indo Digital",
    "Supreme", "Electech", "THP Thunder", "Flash Light"};

// Create a XYChart object of size 600 x 250 pixels
XYChart c = new XYChart(600, 250);

// Add a title to the chart using Arial Bold Italic font
c.addTitle("Revenue Estimation - Year 2002", "Arial Bold Italic");

// Set the plotarea at (100, 30) and of size 400 x 200 pixels. Set the plotarea border, background
// and grid lines to Transparent
c.setPlotArea(100, 30, 400, 200, Chart.Transparent, Chart.Transparent, Chart.Transparent,
    Chart.Transparent, Chart.Transparent);

// Add a bar chart layer using the given data. Use a gradient color for the bars, where the gradient
// is from dark green (0x008000) to white (0xffffff)
BarLayer layer = c.addBarLayer(data, c.gradientColor(100, 0, 500, 0, 0x008000, 0xffffff));

// Swap the axis so that the bars are drawn horizontally
c.swapXY(true);

// Set the bar gap to 10%
layer.setBarGap(0.1);

// Use the format "US$ xxx millions" as the bar label
layer.setAggregateLabelFormat("US$ {value} millions");

// Set the bar label font to 10pt Times Bold Italic/dark red (0x663300)
layer.setAggregateLabelStyle("Times New Roman Bold Italic", 10, 0x663300);

// Set the labels on the x axis
TextBox textbox = c.xAxis().setLabels(labels);

// Set the x axis label font to 10pt Arial Bold Italic
textbox.setFontStyle("Arial Bold Italic");
textbox.setFontSize(10);

// Set the x axis to Transparent, with labels in dark red (0x663300)
c.xAxis().setColors(Chart.Transparent, 0x663300);

// Set the y axis and labels to Transparent
c.yAxis().setColors(Chart.Transparent, Chart.Transparent);

// Output the chart
WebChartViewer viewer = new WebChartViewer(request, "chart1");
viewer.setChart(c, Chart.SVG);

// Include tool tip for the chart
viewer.setImageMap(c.getHTMLImageMap("", "", "title='{xLabel}: US${value} millions'"));
%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Borderless Bar Chart&lt;/title&gt;
    &lt;!-- Include ChartDirector Javascript Library to support chart interactions --&gt;
    &lt;script type="text/javascript" src="cdjcv.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body style="margin:5px 0px 0px 5px"&gt;
    &lt;div style="font:bold 18pt verdana;"&gt;
        Borderless Bar Chart
    &lt;/div&gt;
    &lt;hr style="border:solid 1px #000080; background:#000080" /&gt;
    &lt;div style="font:10pt verdana; margin-bottom:1.5em"&gt;
        &lt;a href="viewsource.jsp?file=&lt;%=request.getServletPath()%&gt;"&gt;View Source Code&lt;/a&gt;
    &lt;/div&gt;
    &lt;!-- ****** Here is the chart image ****** --&gt;
    &lt;%= viewer.renderHTML(response) %&gt;
&lt;/body&gt;
&lt;/html&gt;</code></div>
</div>
<br><hr class="separator"><div class="copyright">&copy; 2022 Advanced Software Engineering Limited. All rights reserved.</div>
</body>
</HTML>
